package cn.com.cetccst.datacenter.collection;

import android.content.Context;

import androidx.room.Room;

import cn.com.cetccst.datacenter.collection.dao.CollectionConfigDao;
import cn.com.cetccst.datacenter.collection.dao.CollectionDataDao;
import cn.com.cetccst.datacenter.collection.dao.LocationRecordDao;
import cn.com.cetccst.datacenter.collection.dao.TestDao;

public class CollectionRepository {

    private static final String DB_NAME = "security_suite_shared.db";
    private static CollectionRepository INSTANCE;

    private TestDao testDao;
    private LocationRecordDao locationRecordDao;
    private CollectionDataDao collectionDataDao;
    private CollectionConfigDao collectionConfigDao;

    public CollectionRepository(Context context) {
        CollectionDataBase dataBase = Room.databaseBuilder(context, CollectionDataBase.class, DB_NAME)
                .allowMainThreadQueries()
                .build();

        testDao = dataBase.getTestDao();
        locationRecordDao = dataBase.getLocationRecordDao();

        collectionConfigDao = dataBase.getCollectionConfigDao();
        collectionDataDao = dataBase.getCollectionDataDao();

    }

    public static CollectionRepository getInstance() {
        return INSTANCE;
    }

    public static void initialize(Context context) {
        INSTANCE = new CollectionRepository(context);
    }

    public TestDao getTestDao() {
        return testDao;
    }

    public LocationRecordDao getLocationRecordDao() {
        return locationRecordDao;
    }

    public CollectionDataDao getCollectionDataDao() {
        return collectionDataDao;
    }

    public CollectionConfigDao getCollectionConfigDao() {
        return collectionConfigDao;
    }
}
